<template>
  <div class="Ly_wrapper">

      <van-nav-bar title="课程详情" left-arrow @click-left="onClickLeft" fixed>
        <template #right>
          <img class="Ly_icon" src="../../../assets/share.png" alt="" />
        </template>
      </van-nav-bar>

      <!-- 标题部分开始 -->
      <div class="Ly_detailTop" v-if="detailList.info">
        <div style="font-size: 16px">{{ detailList.info.title }}</div>
        <van-icon name="star-o" class="Ly_Topicon" />
        <div class="Ly_free">
          <img src="../../../assets/gold.png" alt="" />
          {{ detailList.info.price }}.00
        </div>
        <div class="Ly_text">
          共{{ detailList.info.total_periods }}课时 |
          {{ detailList.info.sales_num }} 人已报名
        </div>
      </div>
      <!-- 标题部分结束 -->

      <!-- 教学团队开始 -->
      <div class="Ly_teachingTeam Ly_margin" v-if="detailList.teachers">
        <div>教学团队</div>
        <div class="Ly_teacher">
          <img :src="detailList.teachers[0].avatar" alt="" />
          <div class="Ly_teacherName">
            {{ detailList.teachers[0].teacher_name }}
          </div>
        </div>
      </div>
      <!-- 教学团队结束 -->

      <!-- 课程介绍开始 -->
      <div class="Ly_introduce Ly_margin">
        <div>课程介绍</div>
      </div>
      <!-- 课程介绍结束 -->

      <!-- 课程大纲开始 -->
      <div class="Ly_outline Ly_margin">
        <div>课程大纲</div>
        <ul v-for="(item, index) in outLine" :key="index">
          <li>{{ item.periods_title }}</li>
        </ul>
      </div>
      <!-- 课程大纲结束 -->

      <!-- 课程评价开始 -->
      <div class="Ly_comment Ly_margin">
        <div>课程评价</div>
        <div
          class="Ly_commentBox"
          v-for="(item, index) in comment"
          :key="index"
        >
          <img :src="item.avatar" alt="" />
          <div>
            <div>
              {{ item.created_at }}
              <van-rate
                v-model="value"
                :size="16"
                color="#ea7a2f"
                void-icon="star"
                void-color="#eee"
              />
            </div>
            <div class="Ly_content">{{ item.content }}</div>
          </div>
        </div>
      </div>
      <!-- 课程评价结束 -->

      <!-- 立即报名按钮开始 -->
      <button class="Ly_btn">立即报名</button>
      <!-- 立即报名按钮结束 -->
  </div>
</template>

<script>
import { Ly_comment, Ly_detail, Ly_outline } from "../../../../request/http";
export default {
  // 组件名称
  name: "",
  // 组件参数 接收来自父组件的数据
  props: [],
  // 局部注册的组件
  components: {},
  // 组件状态值
  data() {
    return {
      detailList: [
        {
          info: {
            title: "",
          },
        },
      ],
      outLine: [], // 课程大纲
      comment: [], // 课程详情
      value: 5,
    };
  },
  // 计算属性
  computed: {},
  // 侦听器
  watch: {},
  // 组件方法
  methods: {
    // 课程详情
    async detail() {
      var id = this.$route.query.id;
      const res = await Ly_detail(id);
      this.detailList = res;
      //   console.log(this.detailList);
    },
    // 课程大纲
    async outline() {
      var id = this.$route.query.id;
      const res = await Ly_outline(id);
      this.outLine = res;
      //   console.log(this.outLine);
    },
    // 课程评价
    async comments() {
      var id = this.$route.query.id;
      const res = await Ly_comment(id);
    //   console.log(res);
      this.comment = res.list;
    },
    // 返回上一级
    onClickLeft() {
      this.$router.go(-1);
    },
  },
  mounted() {
    this.detail(); // 课程详情
    this.outline(); // 课程大纲
    this.comments(); // 课程评价
  },
};
</script>
<style lang='scss' scoped>
.Ly_wrapper {
    background: #f0f2f5;
}
.Ly_icon {
  width: 16px;
  height: 20px;
}
// 标题部分开始
.Ly_detailTop {
  position: relative;
  width: 100%;
  background: #fff;
  padding: 14px;
  box-sizing: border-box;
  margin-top: 40px;
  .Ly_Topicon {
    position: absolute;
    top: 10px;
    right: 24px;
    color: #7b7b7b;
  }
  .Ly_free {
    font-size: 16px;
    color: red;
    display: flex;
    align-items: center;
    padding-top: 10px;
    box-sizing: border-box;
    img {
      width: 18px;
      height: 16px;
    }
  }
  .Ly_text {
    font-size: 14px;
    color: #8c8c8c;
    margin-top: 18px;
  }
}
// 标题部分结束
.Ly_margin {
  margin-top: 18px;
  background: #fff;
  font-size: 16px;
  padding: 16px 10px;
  box-sizing: border-box;
}
// 教学团队开始
.Ly_teachingTeam {
  height: 156px;
  .Ly_teacher {
    margin-left: 16px;
    margin-top: 20px;
    img {
      width: 40px;
      height: 40px;
      border-radius: 50%;
    }
    .Ly_teacherName {
      font-size: 14px;
      color: #595959;
    }
  }
}
// 教学团队结束

// 课程介绍开始
.Ly_introduce {
  height: 98px;
}
// 课程介绍结束

// 课程大纲开始
.Ly_outline {
  ul {
    padding-left: 26px;
    box-sizing: border-box;
    margin-top: 18px;
    font-size: 12px;
    color: #595959;
    li:before {
      content: "";
      width: 6px;
      height: 6px;
      display: inline-block;
      border-radius: 50%;
      background: #eb6100;
      vertical-align: middle;
      margin-right: 14px;
    }
  }
}
// 课程大纲结束

// 课程评价开始
.Ly_comment {
//   height: 200px;
  margin-bottom: 46px;
  .Ly_commentBox {
    display: flex;
    padding: 10px;
    box-sizing: border-box;
    font-size: 12px;
    img {
      width: 30px;
      height: 30px;
      margin-right: 10px;
    }
    .Ly_content {
      margin-top: 12px;
      font-size: 14px;
      color: #999999;
    }
  }
}
// 课程评价结束

// 立即报名按钮开始
.Ly_btn {
  position: fixed;
  bottom: 0;
  width: 100%;
  height: 46px;
  border: none;
  background: #eb6100;
  color: #fff;
  font-size: 20px;
}
// 立即报名按钮结束
</style>
